package com.spittr.web;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.annotation.ServiceWithTransaction;
import com.spittr.web.model.SysMenu;
import com.spittr.web.repository.HibernateRepository;

/**
 * 
 * @author zoe
 * 2017年2月9日
 */
@ServiceWithTransaction
//或者如下
//@Service
//@Transactional
public class RepositoryService {
	
	@Autowired
	private HibernateRepository<SysMenu> hibernateRepository;
	
	public String repository(){
		repository2();
		SysMenu entity = hibernateRepository.queryEntityById(SysMenu.class,"1");
		SysMenu t = new SysMenu();
		t.setId("134");
		t.setMenuCode("123");
		hibernateRepository.saveOrUpdateEntity(t);
		SysMenu t2 = new SysMenu();
		t2.setId("138");
		hibernateRepository.saveOrUpdateEntity(t2);
		List<String> list = new ArrayList<String>();
		list.get(5);
		return "repository";
	}
	public String repository2(){
		SysMenu t = new SysMenu();
		t.setId("444");
		t.setMenuCode("555");
		hibernateRepository.saveOrUpdateEntity(t);
		SysMenu t2 = new SysMenu();
		t2.setId("555");
		hibernateRepository.saveOrUpdateEntity(t2);
		return "repository";
	}
}
